home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_204 / teacher / teacher.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  124 lines

  1. #include <intuition/intuitionbase.h>
  2. #include <graphics/gfxbase.h>
  3. #include <devices/trackdisk.h>
  4. #include <stdio.h>
  5.  
  6. struct NewWindow TinyWindow={
  7.     0,0,1,1,-1,-1,NULL,NULL,NULL,NULL,
  8.     "System Request",NULL,NULL,0,0,0,0,WBENCHSCREEN};
  9.  
  10. struct NewScreen MyScreen={
  11.     0,0,320,0,5,NULL,CUSTOMSCREEN,NULL,NULL,NULL,NULL};
  12.  
  13. struct NewWindow MyWindow={
  14.     0,0,320,0,-1,-1,NULL,BORDERLESS|ACTIVATE,NULL,NULL,
  15.     NULL,NULL,0,0,0,0,CUSTOMSCREEN};
  16.  
  17. struct IntuiText guru3={
  18.     0,1,JAM2,15,25,NULL,"Select CANCEL to reset/debug",NULL};
  19. struct IntuiText guru2={
  20.     0,1,JAM2,23,15,NULL,"Finish ALL disk activity",&guru3};
  21. struct IntuiText guru1={
  22.     0,1,JAM2,15,5,NULL,"Software error - task held",&guru2};
  23.  
  24. struct IntuiText retry={
  25.     0,1,JAM2,7,3,NULL,"Retry",NULL};
  26. struct IntuiText cancel={
  27.     0,1,JAM2,7,3,NULL,"Cancel",NULL};
  28.  
  29. UBYTE guru[]=
  30.     "\x00\x00\xf           Software Failure.      Press left mouse button to continue.\x00\xff\x00\x00\x20                        Guru Meditation #00000004.00F8F360\x00";
  31.  
  32. USHORT empty[]={0,0};
  33. BYTE diskbuffer[1024];
  34.  
  35. struct Window *Window;
  36. struct Screen *Screen, *scr;
  37. struct IntuitionBase *IntuitionBase;
  38. struct GfxBase *GfxBase;
  39. struct ViewPort *vp;
  40. struct Port *diskport;
  41. struct IOStdReq *diskreq;
  42. char confile[]="CON:90/60/460/60/Teacher (Guru!) by Jonathan Potter";
  43. FILE *con;
  44.  
  45. main(argc,argv)
  46. int argc;
  47. char **argv;
  48. {
  49.     int a,error,x;
  50.     IntuitionBase=OpenLibrary("intuition.library",0);
  51.     GfxBase=OpenLibrary("graphics.library",0);
  52.     Window=OpenWindow(&TinyWindow);
  53.     scr=Window->WScreen;
  54.     MyScreen.Height=scr->Height;
  55.     MyWindow.Height=scr->Height;
  56.     loop:
  57.     error=AutoRequest(Window,&guru1,&retry,&cancel,NULL,NULL,320,72);
  58.     if (error==TRUE) goto loop;
  59.     CloseWindow(Window);
  60.     (VOID) DisplayAlert(RECOVERY_ALERT,guru,42);
  61.     Screen=OpenScreen(&MyScreen);
  62.     MyWindow.Screen=Screen;
  63.     Window=OpenWindow(&MyWindow);
  64.     SetPointer(Window,&empty,0,0,0,0);
  65.     vp=&(Screen->ViewPort);
  66.     SetRGB4(vp,0,0x7,0x7,0x7);
  67.     for (a=0;a<100000;a++);
  68.     SetRGB4(vp,0,0xb,0xb,0xb);
  69.     for (a=0;a<100000;a++);
  70.     SetRGB4(vp,0,0xf,0xf,0xf);
  71.     for (a=0;a<100000;a++);
  72.     diskport=CreatePort(0,0);
  73.     diskreq=CreateStdIO(diskport);
  74.     MoveBlocks(0,2);
  75.     for (a=1;a<100000;a++);
  76.     MoveBlocks(0,20);
  77.     for (a=1;a<3;a++)
  78.         if (DriveThere(a)) MoveBlocks(a,8);
  79.     MoveBlocks(0,10);
  80.     CloseWindow(Window);
  81.     CloseScreen(Screen);
  82.     DeletePort(diskport);
  83.     DeleteStdIO(diskreq);
  84.     CloseLibrary(IntuitionBase);
  85.     CloseLibrary(GfxBase);
  86.     if (argc==0) con=fopen(confile,"w");
  87.     else con=stdout;
  88.     fprintf(con,"\x9B;3mHa Ha Ha Ha Ha!\x9B;0;1m Had you worried, eh?\x9B;0m\n");
  89.     if (argc==0) {
  90.         for (x=0;x<500000;x++);
  91.         fclose(con);
  92.     }
  93.     exit(0);
  94. }
  95.  
  96. MoveBlocks(drive,h)
  97. int drive,h;
  98. {
  99.     int l;
  100.     OpenDevice("trackdisk.device",drive,diskreq,0);
  101.     for (l=0;l<h;l++) {
  102.         diskreq->io_Command=TD_SEEK;
  103.         diskreq->io_Offset=l*2048;
  104.         DoIO(diskreq);
  105.         diskreq->io_Command=CMD_READ;
  106.         diskreq->io_Length=1024;
  107.         diskreq->io_Data=(APTR)diskbuffer;
  108.         diskreq->io_Offset=l*2048;
  109.         DoIO(diskreq);
  110.     }
  111.     diskreq->io_Length=0;
  112.     diskreq->io_Command=TD_MOTOR;
  113.     DoIO(diskreq);
  114.     CloseDevice(diskreq);
  115. }
  116.  
  117. DriveThere(drive)
  118. int drive;
  119. {
  120.     if ((OpenDevice("trackdisk.device",drive,diskreq,0))!=0) return(FALSE);
  121.     CloseDevice(diskreq);
  122.     return(TRUE);
  123. }
  124.